package gold.digger;


/**
 * Created by fanzhenyu02 on 2020/3/1.
 */
public class LC88 {


    public void merge(int[] arr1, int m, int[] arr2, int n) {
        int i = m - 1, j = n - 1, t = m + n - 1;
        while (i >= 0 && j >= 0) {
            arr1[t--] = arr1[i] >= arr2[j] ? arr1[i--] : arr2[j--];
        }

        while (i >= 0) {
            arr1[t--] = arr1[i--];
        }

        while (j >= 0) {
            arr1[t--] = arr2[j--];
        }
    }

    public static void main(String[] args) {
        LC88 an = new LC88();
        int[] nums1 = {1, 2, 3, 0, 0, 0};
        int m = 3;
        int[] nums2 = {2, 5, 6};
        int n = 3;
        an.merge(nums1, m, nums2, n);
        System.out.println(nums1);
    }
}
